package com.threaddemo6;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class NewScheduledThreadPool {
    public static void main(String[] args) throws InterruptedException {
        ScheduledExecutorService ses = Executors.newScheduledThreadPool(10);

        for (int i = 0; i < 10; i++) {
            ses.scheduleAtFixedRate(new Runnable() {
                @Override
                public void run() {
                    System.out.println("执行。。。" + Thread.currentThread().getName());
                }
            },0,1, TimeUnit.SECONDS);
        }

        //让主线程 沉睡 要不然主线程先执行完 我们就看不到定时执行....
        Thread.sleep(20 * 1000);

        ses.shutdown();

    }
}
